package com.tengju.activity.domain.shared;

import java.text.DecimalFormat;
import java.text.NumberFormat;

public class Formatter {


    private Formatter() {
    }

    public static String beautyMoney(Amount amount) {
        return String.format("%.2f", amount.getValue());
    }

    public static String thousandMoneyOfTenMillion (int money) {
        if (money > 10000000) {
            return "1000W+";
        } else {
            return thousandMoney(money);
        }
    }

    // 百位抹0
    public static String formatIndex(int index) {
        index = (index / 100) * 100;
        return thousandMoneyOfTenMillion(index);
    }

    public static String thousandMoney (int money) {
        DecimalFormat format = new DecimalFormat("###,###");
        return format.format(money);
    }

    public static String thousandMoney (double money) {
        DecimalFormat format = new DecimalFormat("###,###.##");
        return format.format(money);
    }

    public static void main(String[] args) {
        System.out.println(thousandMoney(34423423.2342));
    }

    public static String percent(double factor, int digits) {
        NumberFormat nf = NumberFormat.getPercentInstance();
        nf.setMinimumFractionDigits(digits);
        return nf.format(factor);
    }
}
